<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    input {
        color: gray;
    }
    </style>
</head>

<body>
    <input type="text" value="请输入搜索内容" id="txt">
    <script>
        function my$(id) {
            return document.getElementById(id);
        }
       var txtObjet =  my$("txt");

       txtObjet.onfocus = function (){
        txtObjet.value = ""
       }   
       txtObjet.onblur = function (){
        txtObjet.value = "请输入搜索内容"
       } 
    </script>
</body>

</html>